Skip to content

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Oct 31, 2023

Followup to #13 with a few style nits.

item.type === "add"
? {...item, items: item.items.map((addItem) => (addItem.type === "cell" ? resolver(addItem) : addItem))}
: item
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I’m just trying to avoid in-place mutation. It doesn’t really matter since this is only used internally, but since the CellResolver API does a copy-on-write, it feels reasonable to do that here. And it avoids needing to leave a comment warning that this method does in-place mutation.

.concat(
parseResult.imports.filter(({name}) => name.startsWith("./")).map(({name}) => `/_file/${name.slice(2)}`),
parseResult.cells.some((cell) => cell.databases?.length) ? "/_observablehq/database.js" : []
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, again, a trivial nit pick, but this approach avoids a blank line being emitted when the page doesn’t use a database.

@mbostock
Copy link
Member Author

mbostock commented Nov 4, 2023

Folded into #94.

@mbostock mbostock closed this Nov 4, 2023
@mbostock mbostock deleted the mbostock/database-style-nits branch November 4, 2023 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant